#

| Chapter 17 Finding Files with find |

## 17.9 Problems with -newer

You may run into problems with the -newer (17.8) operator if you try to use it twice in the same command. Let's say that you want to find all files that are newer than filea but older than fileb. The obvious way to do this would be with the command:

>     % find . -newer filea ! -newer fileb -print

However, most versions of find can only work with one date at a time. When find reads the date of fileb, it discards the date of filea, and uses fileb's date in both places. So it's really trying to find files that are newer than fileb but older than fileb, and will (obviously) find nothing at all.

You can work around this by figuring out the number of days since filea and fileb were modified, and rewriting the command using two -mtime operators. -mtime isn't afflicted by the same bug.

As with all bugs (or "features"), some vendors may have fixed it. So your system may not be afflicted with the problem. A find expression with two -newer operators apparently works under SunOS 4.1, but not under previous SunOS releases. It also seems to work under SVR4. The GNU version (on the CD-ROM) doesn't have the bug.

- ML

17.8 Exact File Time Comparisons |  | 17.10 Running Commands on What You Find